﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyRandoms
{
    /// <summary>
    /// 产生最基础的随机数，最大值和最小值可以自己配置
    /// </summary>
    public class BaseRandom
    {
        public static int Minimum = 100000;
        public static int Maximal = 999999;
        public static int RandomLength = 6;

        private static string RandomString = "0123456789ABCDEFGHIJKMLNOPQRSTUVWXYZ";
        private static Random Random = new Random(DateTime.Now.Second);

        /// <summary>
        /// 产生随机字符
        /// </summary>
        /// <returns>字符串</returns>
        public static string GetRandomString()
        {
            string returnValue = string.Empty;
            for (int i = 0; i < RandomLength; i++)
            {
                int r = Random.Next(0, RandomString.Length - 1);
                returnValue += RandomString[r];
            }
            return returnValue;
        }
        public static string GetRandomString(int length)
        {
            string returnValue = string.Empty;
            for (int i = 0; i < length; i++)
            {
                int r = Random.Next(0, RandomString.Length - 1);
                returnValue += RandomString[r];
            }
            return returnValue;
        }

        /// <summary>
        /// 获取默认范围内的随机数
        /// </summary>
        /// <returns></returns>
        public static int GetRandomNumber()
        {
            return Random.Next(Minimum, Maximal);
        }

        /// <summary>
        /// 凡湖用户定义的范围内的随机数
        /// </summary>
        /// <param name="minNum">最小值</param>
        /// <param name="maxNum">最大值</param>
        /// <returns></returns>
        public static int GetRandomNumber(int minNum,int maxNum)
        {
            return Random.Next(minNum, maxNum);
        }
    }
}
